app.controller("homePushCtrl", function ($scope, $rootScope, $http) {
    $rootScope.activeSidebar = Class.getConstant('SIDEBAR_PUSH');
    $scope.clientNum = 0;
    $scope.pushMsg = function (clientId) {
        var url = $rootScope.rootUrl + Http.PushMsg;
        var msg = $scope.pushText;
        if (isNull(msg))
            msg = "test pushing...";
        var jsonobj = {Name: clientId, Msg: msg};
        $http.post(url, jsonobj).success(function (data) {
            console.log(data);
        }).error(function (data) {
            alert('发送失败！' + data);
        });
    };

    $scope.refresh = function () {
        $scope.getClientList();
    };

    $scope.getClientList = function () {
        var url = $rootScope.rootUrl + Http.GetClientList;
        $http({method: "POST", url: url}).then(function (data) {
            console.log(data);
            $scope.clientList = data.data.resultMap.data;
            var n = 0;
            for (var i in $scope.clientList) {
                n++;
            }
            console.log(n);
            $scope.clientNum = n;
        });
    }
    $scope.getClientList();
});

function isNull(value) {
    return !(value !== null && value !== undefined && value !== '');
}